package view;

import modle.File;

import java.util.List;

import javax.swing.table.AbstractTableModel;

public class FileTableModel extends AbstractTableModel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	int row;
	int column;
	List<File> data;
	String[] columnNames = { "FileName", "File Path" };

	public FileTableModel() {
	}

	public int getColumnCount() {
		return columnNames.length;
	}

	@Override
	public String getColumnName(int c) {
		if (columnNames != null)
			return columnNames[c];
		else
			return null;
	}

	public List<File> getData() {
		return data;
	}

	public int getRowCount() {
		if (data == null)
			return 0;
		else
			return data.size();
	}

	public Object getValueAt(int row, int col) {
		String value = null;
		if (data == null)
			return null;
		File file = data.get(row);
		switch (col) {
		case 0:
			value = file.getFileName();
			break;
		case 1:
			value = file.getFilePath();
			break;
		}
		return value;
	}

	public void setData(List<File> data) {
		this.data = data;
		this.fireTableDataChanged();

	}
}